package com.odp.mapper;


import com.odp.entity.User;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserMapper {
    @Select("select * from t_user")
    public List<User> selectAll();

    //发帖数+1
    @Update("update t_user set posts_number=posts_number+1 where user_id=#{userId}")
    public int addPostNum(int userId);

    //粉丝数+1
    @Update("update t_user set followers=followers+1 where user_id=#{userId}")
    public int addFollowers(int userId);

    //根据id拿到名字
    @Select("select name from t_user where user_id=#{userId}")
    public String getUserNameById(int userId);

    //根据id拿到头像
    @Select("select avatar from t_user where user_id=#{userId}")
    public String getAvatarById(int userId);
}